Skip to content

[Distributed Optimizer] Fix transpose creation when keep_fp8_weight_transpose_cache=False#501

Open
sudhu2k wants to merge 1 commit intodevfrom
sudhu/distiboptim_fp8_transpose_cache_fix
Open

[Distributed Optimizer] Fix transpose creation when keep_fp8_weight_transpose_cache=False#501
sudhu2k wants to merge 1 commit intodevfrom
sudhu/distiboptim_fp8_transpose_cache_fix

Conversation

@sudhu2k
Copy link
Contributor

@sudhu2k sudhu2k commented Mar 20, 2026

Summary

Fixes a bug where post_all_gather_processing created transpose for Float8Tensor weights even when keep_fp8_weight_transpose_cache=False, leading to assertion failures in Linear forward.

Problem

With keep_fp8_weight_transpose_cache=False, quantizer.columnwise_usage is set to False (e.g. on ROCm/AMD). post_all_gather_processing was still creating transpose via _create_transpose() because it did not respect columnwise_usage. This triggered the assertion in Linear forward: expected _transpose to be None or an empty tensor when transpose cache is disabled.

Solution

  • Update post_all_gather_processing in utils.py so it only creates transpose when model_weight._quantizer.columnwise_usage is True.
  • Parametrize test_cast_master_weights_to_fp8 with keep_fp8_weight_transpose_cache=True and False to cover both cases.

Testing

  • test_cast_master_weights_to_fp8 with keep_fp8_weight_transpose_cache=False now passes.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

… add unit test when using distributed optimizers
@sudhu2k sudhu2k changed the title Fix transpose creation when keep_fp8_weight_transpose_cache=False and… [Distributed Optimizer] Fix transpose creation when keep_fp8_weight_transpose_cache=False Mar 20, 2026
@sudhu2k sudhu2k self-assigned this Mar 20, 2026
# Delayed scaling and per-tensor current scaling: if backend does not support
# non-transposed FP8 GEMM, pre-create the transpose.
if not is_non_tn_fp8_gemm_supported():
if model_weight._quantizer.columnwise_usage and not is_non_tn_fp8_gemm_supported():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment or guard the changes

quantizations.append("fp8_block")

manual_post_all_gather_processings = [False, True]
keep_fp8_weight_transpose_caches = [True, False]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be only True on CUDA and better name it keep_fp8_weight_transpose_cache - to match the name of parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants